<let/items=[0, 1, 2]/>
<button onClick() { items = [...items, items.length] }/>

<const/sum = function sum(i = 0) {
  return i >= items.length ? 0 : items[i] + sum(i + 1)
}>
<div>${sum()}</div>